const { DataTypes } = require('sequelize');
const sequelize = require('../db');

// 定义数据模型
exports.projectModel = sequelize.define(
	'project',
	{
		name: {
			type: DataTypes.STRING,
			allowNull: false,
			comment: '项目名称'
		},
		url: {
			type: DataTypes.STRING,
			allowNull: true,
			comment: '项目地址'
		},
		github: {
			type: DataTypes.STRING,
			allowNull: true,
			comment: '仓库地址'
		},
		description: {
			type: DataTypes.STRING,
			allowNull: true,
			comment: '项目描述',
			defaultValue: ''
		},
		thumb: {
			type: DataTypes.STRING,
			allowNull: true,
			comment: '缩略图'
		},
		order: {
			type: DataTypes.INTEGER,
			allowNull: true,
			comment: '排序',
			defaultValue: 1
		}
	},
	{
		freezeTableName: true,
		deletedAt: true,
		defaultScope: {
			attributes: { exclude: ['createdAt', 'updatedAt'] } // 默认排除 createdAt 和 updatedAt 字段
		}
	}
);
